<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>AIfES 2: aimath_q7_cmsis.h File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
</script>
<script type="text/javascript" async="async" src="https://cdn.jsdelivr.net/npm/mathjax@2/MathJax.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="AIfES_logo_small.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">AIfES 2
   &#160;<span id="projectnumber">2.0.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('aimath__q7__cmsis_8h.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">aimath_q7_cmsis.h File Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p><a href="aimath__q7__cmsis_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a046b3b2f59da4e06cf2be75aed10f342"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="aimath__q7__cmsis_8h.html#a046b3b2f59da4e06cf2be75aed10f342">aimath_q7_cmsis_linear32_bt</a> (const <a class="el" href="structaitensor.html">aitensor_t</a> *a, const <a class="el" href="structaitensor.html">aitensor_t</a> *b, const <a class="el" href="structaitensor.html">aitensor_t</a> *c, <a class="el" href="structaitensor.html">aitensor_t</a> *result)</td></tr>
<tr class="memdesc:a046b3b2f59da4e06cf2be75aed10f342"><td class="mdescLeft">&#160;</td><td class="mdescRight">Performs a matrix multiplication of <a class="el" href="aimath__q7_8h.html">Q7 </a> matrices a and b (transposed) and adds a <a class="el" href="aimath__q31_8h.html">Q31 </a> vector c to each row.  <a href="aimath__q7__cmsis_8h.html#a046b3b2f59da4e06cf2be75aed10f342">More...</a><br /></td></tr>
<tr class="separator:a046b3b2f59da4e06cf2be75aed10f342"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><dl class="section version"><dt>Version</dt><dd>2.2.0 </dd></dl>
<dl class="section copyright"><dt>Copyright</dt><dd>Copyright (C) 2020-2023 Fraunhofer Institute for Microelectronic Circuits and Systems. All rights reserved.<br  />
<br  />
 AIfES is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.<br  />
<br  />
 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.<br  />
<br  />
 You should have received a copy of the GNU Affero General Public License along with this program. If not, see <a href="https://www.gnu.org/licenses/">https://www.gnu.org/licenses/</a>. </dd></dl>
</div><h2 class="groupheader">Function Documentation</h2>
<a id="a046b3b2f59da4e06cf2be75aed10f342"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a046b3b2f59da4e06cf2be75aed10f342">&#9670;&nbsp;</a></span>aimath_q7_cmsis_linear32_bt()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void aimath_q7_cmsis_linear32_bt </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="structaitensor.html">aitensor_t</a> *&#160;</td>
          <td class="paramname"><em>a</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="structaitensor.html">aitensor_t</a> *&#160;</td>
          <td class="paramname"><em>b</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="structaitensor.html">aitensor_t</a> *&#160;</td>
          <td class="paramname"><em>c</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structaitensor.html">aitensor_t</a> *&#160;</td>
          <td class="paramname"><em>result</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Performs a matrix multiplication of <a class="el" href="aimath__q7_8h.html">Q7 </a> matrices a and b (transposed) and adds a <a class="el" href="aimath__q31_8h.html">Q31 </a> vector c to each row. </p>
<p>The addition of the horizontal vector c is performed via broadcast, i.e. element wise in each column Mathematically this broadcast is equal to multiplying c with an vertical vector (with the same number of elements as c) and adding the result to \( a \cdot b^T \).</p>
<p><b>The quantization parameters of the vector c have to be {zero_point = 0, shift = a.shift + b.shift}!</b></p>
<p class="formulaDsp">
\[ result = a \cdot b + \left( \begin{array}{c} 1 \\ 1 \\ \vdots \\ 1 \\ \end{array}\right) \cdot c \]
</p>
<p>Example: </p><p class="formulaDsp">
\[ a = \left( \begin{array}{rrr} 1 &amp; 2 &amp; 3 \\ 4 &amp; 5 &amp; 6 \\ 7 &amp; 8 &amp; 9 \end{array}\right) \]
</p>
<p class="formulaDsp">
\[ b = \left( \begin{array}{rr} 1 &amp; 0 &amp; 0 \\ 0 &amp; 1 &amp; 0 \end{array}\right) \]
</p>
<p class="formulaDsp">
\[ c = \left( \begin{array}{rr} 2 &amp; 5 \end{array}\right) \]
</p>
<p class="formulaDsp">
\[ result = a \cdot b^T + \left( \begin{array}{r} 1 \\ 1 \\ 1 \\ \end{array}\right) \cdot c \]
</p>
<p class="formulaDsp">
\[ = \left( \begin{array}{rr} 1 &amp; 2 \\ 4 &amp; 5 \\ 7 &amp; 8 \end{array}\right) + \left( \begin{array}{rr} 2 &amp; 5 \\ 2 &amp; 5 \\ 2 &amp; 5 \end{array}\right) \]
</p>
<p class="formulaDsp">
\[ = \left( \begin{array}{rr} 3 &amp; 7 \\ 6 &amp; 10 \\ 9 &amp; 13 \end{array}\right) \]
</p>
<p>Example: </p><div class="fragment"><div class="line">uint16_t a_shape[2] = {3, 3};</div>
<div class="line"><a class="code" href="structaimath__q7__params.html">aimath_q7_params_t</a> a_params = {1, 0}; <span class="comment">// {shift, zero point}</span></div>
<div class="line">int8_t a_data[3*3] = { 2,  4,  6,</div>
<div class="line">                       8, 10, 12,</div>
<div class="line">                      14, 16, 18};</div>
<div class="line"><a class="code" href="structaitensor.html">aitensor_t</a> a = AITENSOR_2D_Q7(a_shape, &amp;a_params, a_data);</div>
<div class="line"> </div>
<div class="line">uint16_t b_shape[2] = {2, 3};</div>
<div class="line"><a class="code" href="structaimath__q7__params.html">aimath_q7_params_t</a> b_params = {2, 0}; <span class="comment">// {shift, zero point}</span></div>
<div class="line">int8_t b_data[2*3] = {4, 0, 0,</div>
<div class="line">                      0, 4, 0};</div>
<div class="line"><a class="code" href="structaitensor.html">aitensor_t</a> b = AITENSOR_2D_Q7(b_shape, &amp;b_params, b_data);</div>
<div class="line"> </div>
<div class="line">uint16_t c_shape[2] = {1, 2};</div>
<div class="line"><a class="code" href="structaimath__q31__params.html">aimath_q31_params_t</a> c_params = {3, 0}; <span class="comment">// {shift, zero point}</span></div>
<div class="line">int32_t c_data[1*2] = {16, 40};</div>
<div class="line"><a class="code" href="structaitensor.html">aitensor_t</a> c = AITENSOR_2D_Q31(c_shape, &amp;c_params, c_data);</div>
<div class="line"> </div>
<div class="line">uint16_t result_shape[2] = {3, 2};</div>
<div class="line"><a class="code" href="structaimath__q7__params.html">aimath_q7_params_t</a> result_params = {1, 0}; <span class="comment">// {shift, zero point}</span></div>
<div class="line">int8_t result_data[3*2];</div>
<div class="line"><a class="code" href="structaitensor.html">aitensor_t</a> result = AITENSOR_2D_Q7(result_shape, &amp;result_params, result_data);</div>
<div class="line"> </div>
<div class="line"><a class="code" href="aimath__q7__cmsis_8h.html#a046b3b2f59da4e06cf2be75aed10f342">aimath_q7_cmsis_linear32_bt</a>(&amp;a, &amp;b, &amp;c, &amp;result);</div>
<div class="line"> </div>
<div class="line"><a class="code" href="aimath__basic_8h.html#ab10c8d06990943806f0be8fcc6af03fc">print_aitensor</a>(&amp;result);</div>
<div class="ttc" id="aaimath__basic_8h_html_ab10c8d06990943806f0be8fcc6af03fc"><div class="ttname"><a href="aimath__basic_8h.html#ab10c8d06990943806f0be8fcc6af03fc">print_aitensor</a></div><div class="ttdeci">void print_aitensor(const aitensor_t *tensor)</div><div class="ttdoc">Printing a tensor to console.</div></div>
<div class="ttc" id="aaimath__q7__cmsis_8h_html_a046b3b2f59da4e06cf2be75aed10f342"><div class="ttname"><a href="aimath__q7__cmsis_8h.html#a046b3b2f59da4e06cf2be75aed10f342">aimath_q7_cmsis_linear32_bt</a></div><div class="ttdeci">void aimath_q7_cmsis_linear32_bt(const aitensor_t *a, const aitensor_t *b, const aitensor_t *c, aitensor_t *result)</div><div class="ttdoc">Performs a matrix multiplication of Q7  matrices a and b (transposed) and adds a Q31  vector c to eac...</div></div>
<div class="ttc" id="astructaimath__q31__params_html"><div class="ttname"><a href="structaimath__q31__params.html">aimath_q31_params</a></div><div class="ttdoc">Parameters used for the quantized Q31  values, used as property of a tensor.</div><div class="ttdef"><b>Definition:</b> aimath_q31.h:149</div></div>
<div class="ttc" id="astructaimath__q7__params_html"><div class="ttname"><a href="structaimath__q7__params.html">aimath_q7_params</a></div><div class="ttdoc">Parameters used for the quantized Q7  values, used as property of a tensor.</div><div class="ttdef"><b>Definition:</b> aimath_q7.h:148</div></div>
<div class="ttc" id="astructaitensor_html"><div class="ttname"><a href="structaitensor.html">aitensor</a></div><div class="ttdoc">A tensor in AIfES.</div><div class="ttdef"><b>Definition:</b> aifes_math.h:89</div></div>
</div><!-- fragment --><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">*a</td><td>Q7 matrix a (2D tensor of shape [N x K]) </td></tr>
    <tr><td class="paramname">*b</td><td>Q7 matrix b (2D tensor of shape [M x K]) </td></tr>
    <tr><td class="paramname">*c</td><td>Q31 vector c (2D tensor of shape [1 x M] or 1D tensor of shape [M]) </td></tr>
    <tr><td class="paramname">*result</td><td>Resulting Q7 matrix (2D tensor of shape [N x M]) </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li><li class="navelem"><a class="el" href="dir_1e5d3661ed79af157d57e64a38265d09.html">basic</a></li><li class="navelem"><a class="el" href="dir_268d9b67eb3e49a787e31e6186fb3c5a.html">cmsis</a></li><li class="navelem"><a class="el" href="dir_28bb787bfa86207874269dc6cecb6d32.html">aimath</a></li><li class="navelem"><a class="el" href="aimath__q7__cmsis_8h.html">aimath_q7_cmsis.h</a></li>
    <li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1 </li>
  </ul>
</div>
</body>
</html>
